﻿@model protogen.site.Controllers.HomeController.IndexModel
@{
    ViewData["Title"] = "Generator";
}
<h2>@ViewData["Title"].</h2>
<p><a href="/about">Wait... what is this?</a></p>
<p>If this tool has been useful: <a href="https://www.buymeacoffee.com/marcgravell" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" /></a></p>
<section>
    <h3>.proto Schema (can be <a href="https://developers.google.com/protocol-buffers/docs/proto">proto2</a> or <a href="https://developers.google.com/protocol-buffers/docs/proto3">proto3</a>):</h3>
    <p>Pending work items in code generated by protogen (protobuf-net):</p>
    <ul>
        <li>switch to bitwise mask ops for optional field tracking (rather than nullable-per-field)</li>
        <li>intellisense comments</li>
    </ul>
    <div>
        <button id="generatecsharp">Generate</button>
        <select id="tooling">
            <optgroup label="protobuf-net @Model.LibVersion">
                <option value="protogen:C#" selected="@(Model.LangVer.StartsWith("cs"))">(protogen) C#</option>
                <option value="protogen:VB" selected="@(Model.LangVer.StartsWith("vb"))">(protogen) VB</option>
            </optgroup>
            @if (Model.CanUseProtoc)
            {
                <optgroup label="@Model.ProtocVersion">
                    @foreach (var option in protogen.site.Controllers.HomeController.ProtocTooling.Options)
                    {
                        <option value="@option.Tooling" selected="@(Model.LangVer == option.Tooling)">(protoc) @option.Caption</option>
                    }
                </optgroup>
            }
        </select>
        @if (Model.CanUseProtoc)
        {
            <span>(note: only single-file outputs work currently; need tabbed editor)</span>
        }
        else
        {
            <span>(sorry, protoc is not available: @Model.ProtocVersion)</span>
        }
    </div>
    <div title="with the command line tools: +oneof=...">
        <label for="opt_oneof"><code>oneof</code> should use enum</label>&nbsp;<input type="checkbox" id="opt_oneof" value="enum" checked="@Model.OneOfEnum" />
        <a target="_blank" href="#gc545f903467fd7fa441ad80c5433d331">or specify in the .proto</a>
    </div>
    <div title="">
        <label for="opt_listset"><code>repeated</code> should emit <code>set</code> accessors</label>&nbsp;<input type="checkbox" id="opt_listset" value="yes" />
    </div>
    <div title="with the command line tools: +langver=...">
        <label for="opt_langver">Language Version</label>&nbsp;<select id="opt_langver">
            <option value="" selected="@(Model.LangVer == "")">(latest/default)</option>
            <optgroup label="C#">
                <option value="7.1" selected="@(Model.LangVer == "cs7.1")">C# 7.1 - default literals</option>
                <option value="6" selected="@(Model.LangVer == "cs6")">C# 6 - expresson-based (&DoubleRightArrow;) members</option>
                <option value="3" selected="@(Model.LangVer == "cs3")">C# 3 - partial methods</option>
                <option value="2" selected="@(Model.LangVer == "cs2")">C# 2 - downlevel</option>
            </optgroup>
            <optgroup label="VB">
                <option value="14" selected="@(Model.LangVer == "vb14")">VB 14 - readonly automatic properties</option>
                <option value="11" selected="@(Model.LangVer == "vb11")">VB 11 - auto-implemented properties</option>
                <option value="9" selected="@(Model.LangVer == "vb9")">VB 9 - downlevel</option>
            </optgroup>
        </select>
        <a target="_blank" href="#gc545f903467fd7fa441ad80c5433d331">or specify in the .proto</a>
    </div>
    <div title="with the command line tools: +names=...">
        <label for="opt_names">Naming Conventions</label>&nbsp;<select id="opt_names">
                                                                   <option value="auto" selected="@(Model.Names=="auto")">auto - auto-capitalize</option>
            <option value="original" selected="@(Model.Names=="original")">original - use names from schema</option>
        </select>
    </div>
    <div id="protocontainer" style="width:100%; max-width:unset;height:600px;border:1px solid grey"></div>
    <script>

    </script>
    <p>Not sure what to use? How about <a href="https://raw.githubusercontent.com/google/protobuf/master/src/google/protobuf/descriptor.proto">descriptor.proto</a>?</p>
    <p>download <code>protogen</code> <a href="/protogen/protogen 2.3.16.zip">2.3.16 (windows)</a> to use this tool at the command-line, or <a href="https://www.nuget.org/packages/protobuf-net.Protogen">install as a <code>dotnet</code> global tool (multi-platform)</a></p>
</section>
<section id="coderesult" style="display: none;">
    <h3>Generated Code</h3>
    <div id="csharpcontainer" style="width:100%; max-width:unset;height:600px;border:1px solid grey"></div>
</section>
<script src="~/lib/monaco-editor/min/vs/loader.js"></script>

@section Scripts
{
<script src="~/js/home.js" asp-append-version="true"></script>
}